﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlServerCe;
using System.Data;


namespace AnimeCode
{
    public class GlobalVar 
    {
        //Connection String
        public static string connection_string = @"Data Source = |DataDirectory|\AnimeCode.sdf; Password=acer1680";
        public static string image_path = "D:/Anime_Code/";
        //public static string image_path = "C:/wamp/www/ac/images/";
    }
    
    static class Module
    {
        //Function to load AC_Property
        public static string loadVal(string var)
        {
            SqlCeConnection conn = new SqlCeConnection();
            conn.ConnectionString = GlobalVar.connection_string;

            SqlCeCommand cmd;
            SqlCeDataReader dt_reader;
            String sql = null;

            String val = null;

            try
            {
                conn.Open();
                sql = "SELECT property_value FROM AC_Property WHERE property_variable = '" + var + "';";
                cmd = new SqlCeCommand(sql, conn);
                dt_reader = cmd.ExecuteReader();
                while (dt_reader.Read())
                    val = Convert.ToString(dt_reader.GetValue(0));

                conn.Close();
            }
            catch (SqlCeException ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
            }
            return val;
        }
    }
}
